<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>产量物料明细表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<body>
	<div class="demoTable" style="padding:10px 0 0 15px">
    	<!-- 月份 -->
    	<div class="layui-inline">
        	<input class="layui-input" placeholder="请输入月份" name="format" id="format" style="width:230px">
    	</div>
    	 &nbsp; &nbsp; &nbsp; &nbsp;
    	<button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
	</div>
	
	
	<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-blue" id="update" lay-event="gengxin"><i class="layui-icon layui-icon-add-1">更新</i></button>
	</div>
</script>
              
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/js/td/layuiRowspan.js" charset="utf-8"></script>

<script>
layui.use(['table','layer','upload','form'], function(){
	var laydate = layui.laydate;
	var table = layui.table;
	var layer = layui.layer;
    var form = layui.form;
    
  //执行一个laydate实例
	laydate.render({
		elem: '#format', //指定元素
		type: 'month'
	});
  
	var $ = layui.jquery, active = {
			reload:function () {
				var format = $("#format").val();
				table.reload('contenttable',{
					method:'get',
					where:{
						format: format
					}
				}); 
			}
		}
	$('.layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
	table.render({
	    elem: '#test'
	    ,url:'${pageContext.request.contextPath }/report/selectoutputMaterielListReportByMonth.do'
	    ,toolbar: '#toolbarDemo'
	    ,title: '产量物料明细表'
	    ,id :'contenttable'
	    ,limits:[10,20,30]
	    ,request: {   //如果无需自定义请求参数，可不加该参数
            pageName: 'page' //页码的参数名称，默认：page
            ,limitName: 'rows' //每页数据量的参数名，默认：limit
        }
        ,response: {   //如果无需自定义数据响应名称，可不加该参数
            countName: 'total' //规定数据总数的字段名称，默认：count
            ,dataName: 'rows' //规定数据列表的字段名称，默认：data
        }
        ,height: 750
	    ,cols: [[
	    	{
            	field:'t1',
            	title:'', 
            	width:50,
            	align:'center'
	    	},{
	    		field:'t2',
	    		title:'', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'t3', 
	    		title:'', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'t4', 
	    		title:'日期', 
            	width:90,
            	align:'center'
	    	},{
	    		field:'a1', 
	    		title:'1', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a2', 
	    		title:'2', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a3', 
	    		title:'3', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a4', 
	    		title:'4', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a5', 
	    		title:'5', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a6', 
	    		title:'6', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a7', 
	    		title:'7', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a8', 
	    		title:'8', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a9', 
	    		title:'9', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a10', 
	    		title:'10', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a11', 
	    		title:'11', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a12', 
	    		title:'12', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a13', 
	    		title:'13', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a14', 
	    		title:'14', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a15', 
	    		title:'15', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a16', 
	    		title:'16', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a17', 
	    		title:'17', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a18', 
	    		title:'18', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a19', 
	    		title:'19', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a20', 
	    		title:'20', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a21', 
	    		title:'21', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a22', 
	    		title:'22', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a23', 
	    		title:'23', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a24', 
	    		title:'24', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a25', 
	    		title:'25', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a26', 
	    		title:'26', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a27', 
	    		title:'27', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a28', 
	    		title:'28', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a29', 
	    		title:'29', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a30', 
	    		title:'30', 
            	width:150,
            	align:'center'
	    	},{
	    		field:'a31', 
	    		title:'31', 
            	width:150,
            	align:'center'
	    	}
	    ]]
	    ,done: function (res, curr, count) {
            //layuiRowspan('time', 1);
            layuiRowspan(['t1','t2','t3','t4'], 1);//支持数组
            //layuiRowspan("Area", 1, true);
        } 
	});
	//头工具栏事件
	table.on('toolbar(test)', function(obj){
		var checkStatus = table.checkStatus(obj.config.id);
	    switch(obj.event){
	    	case 'gengxin':
	    		layer.confirm('确定更新吗？', function(index){
			   		$("#update").attr("disabled",true);
		    		var format = $("#format").val();
		        	$.ajax({
				    	type:'post',
				    	url:'${pageContext.request.contextPath }/report/gengxinbaobiaoM.do',
				    	data:{"m":format},
				    	dataType : "json",
				    	success:function(data){
				    		if(data > 0){
				    			toastr.success("更新成功！");
				    		}else{
				    			toastr.warning("更新失败！");
							}
				    		setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
								//关闭模态框
								// 父页面刷新
								window.location.reload();  
							},2000); 
			    		}
			   	 	});
		        	layer.close(index);
	    		});
	      	break;
	      	case 'select':
	      		console.log(obj)
	      	break;
	    };
	});
});
toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上

</script>
</body>
</html>